<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 7/25/24
 * Time: 10:23 AM
 */

namespace app\adminapi\lists\media;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\media\MediaAuth;


/**
 * MediaAccount列表
 * Class MediaAccountLists
 * @package app\adminapi\lists
 */
class MediaAuthLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author likeadmin
     * @date 2024/03/04 14:40
     */
    public function setSearch(): array
    {
        return [
            '=' => ['media_id'],
        ];
    }


    public function queryWhere(): array
    {
        return [];
    }


    public function lists(): array
    {
        return MediaAuth::with(['media' => function ($q) {
            $q->withField('id, name');
        }])->where($this->searchWhere)->select()->toArray();
    }


    /**
     * @notes 获取数量
     * @return int
     * @author likeadmin
     * @date 2024/03/04 14:40
     */
    public function count(): int
    {
        return MediaAuth::where($this->searchWhere)->count();
    }
}
